<?php
/**
 * @version		$Id: default_categories.php 772 2012-04-17 19:21:09Z jeffchannell $
 * @package		JCalPro
 * @subpackage	com_jcalpro

**********************************************
JCal Pro
Copyright (c) 2006-2012 Anything-Digital.com
**********************************************
JCalPro is a native Joomla! calendar component for Joomla!

JCal Pro was once a fork of the existing Extcalendar component for Joomla!
(com_extcal_0_9_2_RC4.zip from mamboguru.com).
Extcal (http://sourceforge.net/projects/extcal) was renamed
and adapted to become a Mambo/Joomla! component by
Matthew Friedman, and further modified by David McKinnis
(mamboguru.com) to repair some security holes.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This header must not be removed. Additional contributions/changes
may be added to this header as long as no information is deleted.
**********************************************
Get the latest version of JCal Pro at:
http://anything-digital.com/
**********************************************

 */

defined('JPATH_PLATFORM') or die;
$db = &JFactory::getDBO();
$query = 'select * from #__menu where menutype="categories" and published=1 order by id';
$db->setQuery( $query );
$menuitem = $db->loadObjectList();


?>
<script src="http://code.jquery.com/jquery-latest.js"></script>

<style type="text/css">
	.cat_Checkbox, #save_value, #reset_value{
		float:left;
		font-size:11px;
		color:#606F79;
	}
	#jcl_component .jcal_category .jcal_category_title{
		color:#606F79;	
	}
	#jcl_component .jcal_categories h3{
		color:#606F79;
		font-size:12px;
		line-height:30px;	
	}
	.jcal_categories{
		position:relative;
	}
	div.button{
		position:absolute;
		right:50px;
		bottom:10px;
	}
	div.button a{
		text-decoration:none !important;
	}
	.divselectsub{
		position:absolute;
		right:50px;
		top:20px;
		font-size:11px;
	}
	.divselectsub select{
		font-size:11px;
		width:144px;
		color:#606F79 !important;
	}
	.searchout{
		position:absolute;
		right:50px;
		top:47px;
		font-size:11px !important;	
	}
	.searchout .search{position:relative;}
	.searchout label{display:none;}
	.searchout #mod-search-searchword{
		font-size:11px !important;
		width:137px;
		color:#606F79;
	}
	.searchout .buttonimg{
		background:url(templates/wmc/images/searchimg.png) center center no-repeat;
		width:24px;
		height:20px;
		position:absolute;
		right:0px;
		top:0;
	}
</style>
<?php 
	$date=JRequest::getVar('date','');
	//echo $date;
	$id_menu = $_REQUEST["catcalendar"]; 
?>
<div class="jcal_categories">
	<h3><?php echo JText::_('COM_JCALPRO_CATEGORIES'); ?></h3>
    <form name="formcategoriesfilter" id="formcategoriesfilter" action="index.php?option=com_jcalpro&view=events&date=<?php echo $date; ?>&layout=month&Itemid=494" method="POST">
	<?php //for ($i=0; $i<count($this->categories); $i++) : ?>
    <?php for ($i=0; $i<count($menuitem); $i++) : ?>
	<div class="jcal_category">
            <div class="jcal_category_color" style="background-color: <?php echo $menuitem[$i]->note; ?>;width:30px;">&nbsp;&nbsp;</div>
            <?php
			$checked = '';
            for($p=0; $p<count($id_menu); $p++){
				if($menuitem[$i]->id == $id_menu[$p]){
					$checked = 'checked';
				}
				
			}
			?>
            <input type="checkbox" name="catcalendar[]" class="cat_Checkbox" value="<?php echo $menuitem[$i]->id; ?>" <?php echo $checked;?> >
            <div class="jcal_category_title">
                <!--<a href="index.php?option=com_jcalpro&view=events&layout=month&Itemid=<?php echo $menuitem[$i]->id; ?>">-->
                    <?php echo JCalProHelperFilter::escape($menuitem[$i]->title); ?>
                <!--</a>-->
            </div>
        
    </div>
	<?php endfor; ?>
    	
        <div class="button">
            <input type="submit" id="save_value" name="save_value" value="Filter" />
            <a href="?date=<?php echo $date; ?>"><input type="button" id="reset_value" name="reset_value" value="Reset" /></a>
            <input type="hidden" id="idcategory" name="idcategory" value="<?php echo $_REQUEST["catcalendar"];?>"  />
            <!--<input type="hidden" id="co" name="co" value="<?php echo $co;?>"  />-->
        </div>
    </form>
    <form name="formsubcat" id="formsubcat" action="index.php?option=com_jcalpro&view=events&date=<?php echo $date; ?>&layout=month&Itemid=494" method="POST">
    	<div class="divselectsub">
        	<?php
			$subcatval = $_REQUEST["subcategory"];
			if($subcatval==1){
				$checked1 = 'selected="selected"';
				$checked2 = '';
				$checked3 = '';
				$checked4 = '';
			} 
			if($subcatval==2){
				$checked1 = '';
				$checked2 = 'selected="selected"';
				$checked3 = '';
				$checked4 = '';
			}
			if($subcatval==3){
				$checked1 = '';
				$checked2 = '';
				$checked3 = 'selected="selected"';
				$checked4 = '';
			}
			if($subcatval==4){
				$checked1 = '';
				$checked2 = '';
				$checked3 = '';
				$checked4 = 'selected="selected"';
			}
			?>
        	<select id="subcategory" name="subcategory">
            	<option value="0"><?php echo JText::_('Choose Sub category'); ?></option>
                <option value="1" <?php echo $checked1; ?> ><?php echo JText::_('Monthly promotions (MP)'); ?></option>
                <option value="2" <?php echo $checked2; ?> ><?php echo JText::_('Special promotions (SP)'); ?></option>
                <option value="3" <?php echo $checked3; ?> ><?php echo JText::_('Events (E)'); ?></option>
                <option value="4" <?php echo $checked4; ?> ><?php echo JText::_('Others (O)'); ?></option>
            </select>
            
        </div>
    </form>
    	<div class="searchout">
			<?php
            $document = &JFactory::getDocument();
            $renderer   = $document->loadRenderer('modules');
            $position   = 'position-0';
            $options   = array('style' => 'raw');
            echo $renderer->render($position, $options, null);
            ?>
        </div>
	<div class="jcl_clear"><!--  --></div>
</div>

<script type="text/javascript">
	$('#save_value').click(function($final){
		var final = '';
		$('.cat_Checkbox:checked').each(function(){        
			var values = $(this).val();
			final += values;
			final += ';';
		});
		var response = final.split(";");
	});
	$('#subcategory').change(
		function($valsubcat){
			var valsubcat = $(this).val();
			document.getElementById("formsubcat").submit();
			return valsubcat;
		}
	);
</script>
